//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ellricky.baselib.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;

import com.andr.common.ui.adapter.BaseViewPagerAdapter;
import com.andr.common.widget.tabvp.SimpleFragmentAdapter;
import com.andr.common.widget.tabvp.SimpleTabLayout;
import com.ellricky.baselib.R;

import java.util.List;

public class TabVpView extends FrameLayout {
    private SimpleTabLayout tabLayout;
    private ViewPager viewPager;
    private List<Fragment> fList;

    public TabVpView(@NonNull Context context) {
        super(context);
        this.init(context);
    }

    public TabVpView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.init(context);
    }

    public TabVpView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.init(context);
    }

    private void init(Context context) {
        View.inflate(context, R.layout.base_common_tab_vp, this);
        this.tabLayout = this.findViewById(R.id.tabLayout);
        this.viewPager = this.findViewById(R.id.vp);
    }

    public void setUp(FragmentManager fm, List<Fragment> fList, List<String> tList) {
        this.fList = fList;
        BaseViewPagerAdapter fa = new SimpleFragmentAdapter(fm, fList, tList);
        this.tabLayout.setUp(fa, this.viewPager);
    }

    public Fragment getCurFrg() {
        int curIndex = this.viewPager.getCurrentItem();
        return (Fragment) this.fList.get(curIndex);
    }

    public int getCurrentPos(){
        return viewPager.getCurrentItem();
    }
    public SimpleTabLayout getTabLayout() {
        return tabLayout;
    }
}
